home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Apple II Magazines (PO)
/
Nibble Volume 09, No. 12 (1988-12)(MicroSPARC)(Side A)[a].zip
/
Nibble Volume 09, No. 12 (1988-12)(MicroSPARC)(Side A)[a].po
/
GS.FX.S
< prev
next >
Wrap
Text File
|
1996-12-24
|
10KB
|
292 lines
*
* GS.FX Source Code
* By Peter Stubbs
* Copyright(c) 1988
* MicroSPARC, Inc.
* Concord, MA 01742
*
* Assembler: MERLIN 16
*
TR ADR
XC
XC
ORG $2000 ;Note: program, as written
;is relocatable and will
;run at any address
NEWVIDEO EQU $C029 ;SuperRes/linear softswitch
WAIT EQU $FCA8 ;ROM time delay routine
PALPTR EQU $0 ;3 byte pointer to palette
PALZERO EQU $3 ;pointer to main palette
MAXBLUE EQU $6 ;max. value of blue
ENDVAL1 EQU $7 ;max. value of blue/green
ENDVAL2 EQU $8 ;max. value of red
VIDSAVE EQU $9 ;save video register
CODE EQU $1A ;function code poked here
DELAY EQU $1B ;delay value
START SEC
XCE ;turn emulation mode on
SEP #$30
*
* common code for all three functions
*
LDA NEWVIDEO ;get setting of NEWVIDEO
STA VIDSAVE ;Save for later
ORA #%01000000 ;turn on linear addressing
STA NEWVIDEO ;by setting bit 6
* Set up the pointers to our colour palettes
LDA #<$E19FE0 ;Set up PALPTR to point at
STA PALPTR ;location of palette F
LDA #>$E19FE0
STA PALPTR+1
LDA #^$E19FE0
STA PALPTR+2
LDA #<$E19E00 ;Set up PALZERO to point at
STA PALZERO ;location of palette zero
LDA #>$E19E00
STA PALZERO+1
LDA #^$E19E00
STA PALZERO+2
* Branch here depending on which routine you want
JUMPTBL LDA CODE
BNE :1
BRA INFX ;fade in
:1 CMP #1
BNE :2
BRA OUTFX ;fade out
:2 CMP #2
BNE :3
BRL SCROLLFX ;scroll in
:3 JSR $FF3A ;incorrect code, so ring bell
BRA EXIT ; and exit
*
INFX = * ;Fade-in code starts here
*
CLRPAL LDA #$0 ;Colour to use to clear the
TAX ;palettes (00=black)
LOOP0 STAL $E19FE0,X ;Clears Palette $0F
INX
CPX #$20 ;are we at end of palette ?
BNE LOOP0 ;if not zero next byte
LDY #$1E ;Start fade from last color
FADEIT PER RETURN1-1 ;relocatable version
BRL SETUP2 ;of JSR SETUP2
RETURN1 LDA ENDVAL1 ;Get max val of blue/green
BEQ DONE2 ;if = 0 is no need to fade
LDX #$FF ;so X=0 after next line
COLORUP INX ;turn blue intensity up 1
TXA ;(changes bits 3-0 only)
STA [PALPTR],Y ;Set the new intensity
;in the colour table
PER RETURN3-1 ;relocatable version
BRL PAUSE ;of JSR PAUSE
RETURN3 CPX MAXBLUE ;at maximum blue value yet ?
BNE COLORUP ;if not loop back
LDA ENDVAL1 ;else check green component
CMP #$10 ;is this lowest intensity?
BLT DONE2 ;if yes skip add'n for now
DONE1 TXA ;bump bits 7-4 (green bits)
COLORUP2 CLC ;up one intensity by adding
ADC #$10 ;#%00010000 ($10)
STA [PALPTR],Y ;save new value
PER RETURN4-1 ;relocatable version
BRL PAUSE ;of JSR PAUSE
RETURN4 CMP ENDVAL1 ;at max val for blue/green ?
BNE COLORUP2 ;if not cycle again
DONE2 LDX #$FF ;else start on red byte
COLORUP3 INX
TXA
INY ;To point at high byte
STA [PALPTR],Y ;zero high byte
DEY ;restore Y
PER RETURN5-1 ;relocatable version
BRL PAUSE ;of JSR PAUSE
RETURN5 CPX ENDVAL2 ;at max for this colour?
BNE COLORUP3 ;if not, loop back
DEY ;move to next colour down
DEY ;by moving two bytes down
BPL FADEIT ;cycle until color 0 done
EXIT LDA VIDSAVE ;Restore original NEWVIDEO
STA NEWVIDEO
RTS ;And exit
*
OUTFX = * ;fade-out effect starts here
*
COPYPAL LDY #$00 ;Start at colour zero
OLOOP0 LDA [PALZERO],Y ;get blue/green byte from
TYX ;palette zero and put it in
STAL $E19FE0,X ;same position in pal. $F
INY
LDA [PALZERO],Y ;Get the red colour byte
TYX ;make X = Y
STAL $E19FE0,X ;and copy red colour byte
INY
CPY #$20 ;Are we at the end
BNE OLOOP0
LDY #$00 ;Start fade from 1st colour
OFADEIT PER ORETURN1-1 ;Relocatable version
BRL SETUP2 ;of JSR SETUP2
ORETURN1 LDX ENDVAL2 ;Get max val of red byte
OCLRDWN3 TXA
INY ;To point at high byte
STA [PALPTR],Y ;update red colour byte
DEY ;point Y back at low byte
PER ORETURN2-1 ;Relocatable version
BRL PAUSE ;of JSR PAUSE
ORETURN2 DEX ;turn red intensity down 1
CPX #$FF ;Wrapped from $0 ?
BNE OCLRDWN3 ;if not, reloop
LDX ENDVAL1 ;get max blue/green byte
TXA
OCLRDWN2 STA [PALPTR],Y ;update green colour byte
PER ORETURN3-1 ;relocatable version
BRL PAUSE ;of JSR PAUSE
ORETURN3 CMP #$10 ;lowest intensity ?
BLT ODONE ;if yes, skip the subtract
SEC ;drop bits 7-4 (green) by 1
SBC #$10 ;by subtracting #%00010000
BRA OCLRDWN2 ;(leaves blue unchanged)
ODONE LDX MAXBLUE ;get maximum blue intensity
OCOLRDWN TXA
STA [PALPTR],Y ;update the blue/green
PER ORETURN4-1 ;relocatable version
BRL PAUSE ;of JSR PAUSE
ORETURN4 DEX ;turn blue intensity down 1
CPX #$FF ;Wrapped from $0 ?
BNE OCOLRDWN ;no, so reloop
INY ;move to next colour up
INY ;by moving two bytes up
CPY #$20 ;at end of the palette ?
BNE OFADEIT ;if not, loop back
ORTS LDA VIDSAVE
STA NEWVIDEO
RTS
*
SCROLLFX = * ;scroll code starts here
*
SCLRPAL LDA #$0 ;Colour to use to clear the
TAX ;palettes (00=black)
SLOOP0 STAL $E19FE0,X ;Clear Palette $F
STAL $E19FC0,X ;Clear Palette $E
INX
CPX #$20 ;At end of palette ?
BNE SLOOP0 ;if not zero next byte
LDA #$E ;Start with palette $0E
PER SRETURN0-1 ;relocatable version
BRL SCLRSCB ;of JSR CLRSCB
SRETURN0 LDY #$20 ;start with colour $0F (at
SLOOP1 DEY ;byte $1F in palette & copy
LDA [PALZERO],Y;it from palette $00 to
TYX ;palette $0F
STAL $E19FE0,X ;Store high byte of colour
DEY ;in palette $0F
LDA [PALZERO],Y
TYX
STAL $E19FE0,X ;Store low byte in pal. $0F
LDA #$F ;Display palette for SCB's
PER SRETURN1-1 ;relocatable version
BRL SCLRSCB ;of JSR sCLRSCB
SRETURN1 INY
LDA [PALZERO],Y ;Make pal. $0E same as $0F
TYX
STAL $E19FC0,X ;Store high byte in pal $0E
DEY
LDA [PALZERO],Y
TYX
STAL $E19FC0,X ;store low byte in pal. $0E
DEY ;while we're seeing pal $0F
LDA [PALZERO],Y ;move one more colour into
TYX ;pal. $0E from pal. $00
STAL $E19FC0,X ;store high byte
DEY
LDA [PALZERO],Y
TYX
STAL $E19FC0,X ;store low byte
LDA #$E ;display palette for SCB's
PER SRETURN2-1 ;relocatable version
BRL CLRSCB ;of JSR CLRSCB
SRETURN2 INY
LDA [PALZERO],Y ;Make pal. $0F same as $0E
TYX
STAL $E19FE0,X ;store high byte
DEY
LDA [PALZERO],Y
TYX
STAL $E19FE0,X ;store low byte
CPY #$0 ;done scrolling all colors?
BNE SLOOP1 ;if not cycle through again
SEXIT LDA VIDSAVE ;Restore original NEWVIDEO
STA NEWVIDEO
RTS ;And exit
SCLRSCB LDX #0
SLOOP STAL $E19D00,X ;point all SCB's at the
SPAUSE PHA ;save accumulator
LDA DELAY ;get delay value
JSR WAIT ;call pause ROM routine
NOKEY PLA ;restore accumulator
SRETURN6 INX ;palette in the acc.
CPX #$C8 ;SCB's end at $E19DC8
BNE SLOOP
* Setup is finished so display the screen
LDA NEWVIDEO
ORA #%11000000 ;Turn on linear addressing and super hi
STA NEWVIDEO
RTS
*
* common code for in & out effects
*
SETUP2 LDA [PALZERO],Y ;Get blue/green byte of
STA ENDVAL1 ;colour and save it
AND #%00001111 ;Get intensity of Blue
STA MAXBLUE ;and save it
INY ;so Y indexes high byte
LDA [PALZERO],Y ;Get red byte of colour
STA ENDVAL2 ;and save it
DEY ;so Y indexes low byte
LDA #$F ;So we use palette F
CLRSCB LDX #0
LOOP STAL $E19D00,X ;point all SCB's at the
RETURN6 INX ;palette in the acc.
CPX #$C8 ;SCB's end at $E19DC8
BNE LOOP
* Setup is finished so display the screen
LDA NEWVIDEO
ORA #%11000000 ;Turn on linear addressing and super hi
STA NEWVIDEO
RTS
PAUSE PHA ;save accumulator
LDA DELAY ;get delay value
JSR WAIT ;call pause ROM routine
PLA ;restore accumulator
RTS ;and return
*
END CHK ;MERLIN chk = C5